rpc: add method name length limit#31711
Conversation
|
We control which RPC methods are registered in Geth. I don't see the practical gain from including this PR. |
Even though Geth only registers a fixed set of RPC methods, the error handler currently echoes the entire (unknown) method name back to the caller. An attacker can exploit this by sending a request whose method field is arbitrarily long; Geth will then include that same string verbatim in the error payload. The result is roughly a 2 × bandwidth amplification (request bytes + reflected bytes) that can be repeated at scale to waste network and CPU resources. Returning a constant error message—or at least truncating the reflected method name—would close this vector with virtually no downside. |
This change adds a limit for RPC method names to prevent potential abuse where large method names could lead to large response sizes. The limit is enforced in: - handleCall for regular RPC method calls - handleSubscribe for subscription method calls Added tests in websocket_test.go to verify the length limit functionality for both regular method calls and subscriptions. --------- Co-authored-by: Felix Lange <fjl@twurst.com>
This change adds a limit for RPC method names to prevent potential abuse where large method names could lead to large response sizes. The limit is enforced in: - handleCall for regular RPC method calls - handleSubscribe for subscription method calls Added tests in websocket_test.go to verify the length limit functionality for both regular method calls and subscriptions. --------- Co-authored-by: Felix Lange <fjl@twurst.com>
This change adds a limit for RPC method names to prevent potential abuse where large method names could lead to large response sizes. The limit is enforced in: - handleCall for regular RPC method calls - handleSubscribe for subscription method calls Added tests in websocket_test.go to verify the length limit functionality for both regular method calls and subscriptions. --------- Co-authored-by: Felix Lange <fjl@twurst.com>
This change adds a limit for RPC method names to prevent potential abuse where large method names could lead to large response sizes. The limit is enforced in: - handleCall for regular RPC method calls - handleSubscribe for subscription method calls Added tests in websocket_test.go to verify the length limit functionality for both regular method calls and subscriptions. --------- Co-authored-by: Matus Kysel <MatusKysel@users.noreply.github.com> Co-authored-by: Felix Lange <fjl@twurst.com>
This change adds a limit for RPC method names to prevent potential abuse where large method names could lead to large response sizes. The limit is enforced in: - handleCall for regular RPC method calls - handleSubscribe for subscription method calls Added tests in websocket_test.go to verify the length limit functionality for both regular method calls and subscriptions. --------- Co-authored-by: Felix Lange <fjl@twurst.com>
rpc: add method name length limit
This change adds a limit of 256 characters for RPC method names to prevent potential abuse where large method names could lead to large response sizes.
The limit is enforced in:
Added tests in websocket_test.go to verify the length limit functionality for both regular method calls and subscriptions.